/*
 *	Copyright (c) 2009, libBasement
 *	All rights reserved.
 *	
 *	Redistribution and use in source and binary forms, with or without modification,
 *	are permitted provided that the following conditions are met:
 *	
 *	Redistributions of source code must retain the above copyright notice,
 *	this list of conditions and the following disclaimer.
 *	Redistributions in binary form must reproduce the above copyright notice,
 *	this list of conditions and the following disclaimer in the documentation
 *	and/or other materials provided with the distribution.
 *	Neither the name of the <ORGANIZATION> nor the names of its contributors may
 *	be used to endorse or promote products derived from this software without
 *	specific prior written permission.
 *	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 *	AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 *	THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 *	ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
 *	FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 *	(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 *	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 *	ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *	(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 *	SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef BDictionary_h
#define BDictionary_h 1

#include <BObject.h>
#include <BArray.h>
#include <BEnumerator.h>
#include <BNull.h>

namespace Basement
{
	//TODO: Dictionary needs file support. 
	class Dictionary : public Object
	{
	protected:
		Array *_keys;
		Array *_values;
	public:
		__BObjectStandardFunctions(Dictionary);
		
		virtual void dealloc();
		
		static Dictionary *dictionary() { return Dictionary::alloc()->init()->autorelease< Dictionary * >(); }
		static Dictionary *withObjectsAndKeys(Array *objects, Array *keys);
		static Dictionary *withDictionary(Dictionary *dictionary);
		
		virtual Dictionary *init();
		virtual Dictionary *initWithObjectsAndKeys(Array *objects, Array *keys);
		virtual Dictionary *initWithDictionary(Dictionary *dictionary);
		
		virtual Dictionary *copy() { return Dictionary::alloc()->initWithDictionary(this); }
		
		//Basic Methods
		virtual UInteger count() const;
		virtual Object *objectForKey(Object *key);
		
		virtual Array *objectsForKeys(Array *keys, Object *notFoundMarker = Null::null());
		
		virtual String *description();
		
		//Enumeration
		virtual Array::ObjectEnumerator keyEnumerator() const { return _keys->objectEnumerator(); }
		virtual Array *allKeys() const { return _keys; }
		virtual Array *allKeysForObject(Object *object);
		
		virtual Array::ObjectEnumerator valueEnumerator() const { return _values->objectEnumerator(); }
		virtual Array *allValues() const { return _values; }
		
		//Equality
		virtual bool isEqualToDictionary(Dictionary *dictionary) const;
		virtual bool isEqualTo(Dictionary *dictionary) const { return isEqualToDictionary(dictionary); }
		
		//Mutation
		virtual Dictionary *removeObjectForKey(Object *key);
		virtual Dictionary *setObjectForKey(Object *object, Object *key);
		
		virtual Dictionary *removeAllObjects();
		
		virtual Dictionary *addEntriesFromDictionary(Dictionary *other);
		virtual Dictionary *removeObjectsForKeys(Array *keys);
		
		virtual Dictionary *setDictionary(Dictionary *other);
		
		//Theoretical KVC
		virtual void setValueForKey(Object *value, String *key);
		virtual Object *valueForKey(Object *value, String *key);
	};
}

#endif /* BDictionary_h */
